import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GoodsBannerVO, GoodsBannerForm, GoodsBannerQuery } from '@/api/mall/goodsBanner/types';

/**
 * 查询商品轮播图列表
 * @param query
 * @returns {*}
 */

export const listGoodsBanner = (query?: GoodsBannerQuery): AxiosPromise<GoodsBannerVO[]> => {
  return request({
    url: '/mall/goodsBanner/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品轮播图详细
 * @param id
 */
export const getGoodsBanner = (id: string | number): AxiosPromise<GoodsBannerVO> => {
  return request({
    url: '/mall/goodsBanner/' + id,
    method: 'get'
  });
};

/**
 * 新增商品轮播图
 * @param data
 */
export const addGoodsBanner = (data: GoodsBannerForm) => {
  return request({
    url: '/mall/goodsBanner',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品轮播图
 * @param data
 */
export const updateGoodsBanner = (data: GoodsBannerForm) => {
  return request({
    url: '/mall/goodsBanner',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品轮播图
 * @param id
 */
export const delGoodsBanner = (id: string | number | Array<string | number>) => {
  return request({
    url: '/mall/goodsBanner/' + id,
    method: 'delete'
  });
};
